package org.electrode.base;

import org.electrode.common.NetworkTableVariable;

import edu.wpi.first.wpilibj.PIDController;
import edu.wpi.first.wpilibj.networktables.NetworkTable;
import edu.wpi.first.wpilibj.tables.ITable;

public class PIDValues {
	private final static ITable TABLE = NetworkTable.getTable("SmartDashboard")
			.getSubTable("PID");
	private final NetworkTableVariable p;
	private final NetworkTableVariable i;
	private final NetworkTableVariable d;

	public PIDValues(double p, double i, double d) {
		this.p = new NetworkTableVariable(TABLE, "p", p);
		this.i = new NetworkTableVariable(TABLE, "i", i);
		this.d = new NetworkTableVariable(TABLE, "d", d);
	}

	public void set(double p, double i, double d) {
		this.p.set(p);
		this.i.set(i);
		this.d.set(d);
	}

	public double getP() {
		return this.p.get();
	}

	public double getI() {
		return this.i.get();
	}

	public double getD() {
		return this.d.get();
	}

	public void set(PIDController controller) {
		controller.setPID(getP(), getI(), getD());
	}

	public void setReversed(PIDController controller) {
		controller.setPID(-getP(), -getI(), -getD());

	}
}
